@extends('admin.layout')
@section('title', $title)
@section('content')
<div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                {{$title}}
                <small>请您编辑分类
                    @if(session('info'))
                        <span id="info" class="text-red">{{session('info')}}</span>
                    @endif
                </small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="{{ url('/Admin/index') }}"><i class="fa fa-dashboard"></i>主页</a></li>
                <li><a href="{{ url('/Admin/category/') }}">分类管理</a></li>
                <li class="active">编辑分类</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-8">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">编辑您的分类</h3>
                        </div><!-- /.box-header -->
                        <!-- form start -->
                        <form role="form" action="{{ url('/Admin/category')}}/{{$cateData -> id}}" method="post" enctype="multipart/form-data" >
                            {{ csrf_field() }}
                            {{ method_field("PUT") }}
                            @if (count($errors) > 0)
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif
                            <div class="form-group">
                                <label>父分类</label>
                                <select class="form-control" name="pid">
                                    @foreach($data as $row)
                                    <option
                                    @if($cateData -> pid == $row -> id)
                                    selected="selected"
                                    @endif
                                    @if($cateData -> id == $row -> id)
                                    disabled = "disabled"
                                    @endif
                                     value="{{ $row -> id }}">{{ $row -> catname }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="exampleInputEmail1">请您编辑分类名称</label>
                                    <input type="text" name="catname" value="{{!empty(old('catname'))?old('catname'):$cateData -> catname}}" class="form-control" id="exampleInputEmail1"
                                           placeholder="请您编辑分类名称">
                                </div>
                            </div><!-- /.box-body -->
                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </form>
                    </div><!-- /.box -->
                </div><!--/.col (left) -->
                <!-- right column -->
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
@endsection